<template>
  <div class="exhibitornotice">
    <div class="page-header">
      <div class="container">
        <h1 class="page-title">展商须知</h1>
        <p class="page-subtitle">参展商必须了解的重要信息和注意事项</p>
      </div>
    </div>
    <div class="container">
      <section class="content-section">
        <h2 class="section-title">展商须知</h2>
        <div class="exhibitor-notice">
          <div class="notice-item" v-for="notice in exhibitorNotice" :key="notice.id">
            <h3>{{ notice.title }}</h3>
            <p>{{ notice.content }}</p>
          </div>
        </div>
      </section>

      <section class="content-section">
        <h2 class="section-title">重要提醒</h2>
        <div class="important-reminders">
          <div class="reminder-item" v-for="reminder in importantReminders" :key="reminder.id">
            <div class="reminder-icon">
              <el-icon><component :is="getIconComponent(reminder.icon)" /></el-icon>
            </div>
            <div class="reminder-content">
              <h3>{{ reminder.title }}</h3>
              <p>{{ reminder.description }}</p>
            </div>
          </div>
        </div>
      </section>

      <section class="content-section">
        <h2 class="section-title">参展要求</h2>
        <div class="exhibition-requirements">
          <div class="requirement-category" v-for="category in requirements" :key="category.id">
            <h3>{{ category.title }}</h3>
            <ul class="requirement-list">
              <li v-for="item in category.items" :key="item">{{ item }}</li>
            </ul>
          </div>
        </div>
      </section>

      <section class="content-section">
        <h2 class="section-title">时间安排</h2>
        <div class="schedule-timeline">
          <div class="timeline-item" v-for="(item, index) in scheduleItems" :key="item.id">
            <div class="timeline-marker">{{ index + 1 }}</div>
            <div class="timeline-content">
              <h3>{{ item.title }}</h3>
              <p class="timeline-date">{{ item.date }}</p>
              <p>{{ item.description }}</p>
            </div>
          </div>
        </div>
      </section>
    </div>
  </div>
</template>

<script>
import { ref, onMounted } from 'vue'
import { 
  Warning, 
  Clock, 
  Document, 
  Setting,
  Location,
  User,
  Tools
} from '@element-plus/icons-vue'
import { subpageApi } from '@/api/user'

export default {
  name: 'ExhibitorNotice',
  setup() {
    // 展商须知数据
    const exhibitorNotice = ref([])
    
    // 加载展商须知数据
    const loadExhibitorNotice = async () => {
      try {
        const response = await subpageApi.getSubpageByKey('exhibitors', 'exhibitor-notice')
        if (response && response.code === '200' && response.data) {
          const data = response.data
          if (data.content) {
            try {
              const contentData = JSON.parse(data.content)
              exhibitorNotice.value = contentData.notices || []
            } catch (e) {
              console.error('解析展商须知数据失败:', e)
              exhibitorNotice.value = []
            }
          } else {
            exhibitorNotice.value = []
          }
        } else {
          exhibitorNotice.value = []
        }
      } catch (error) {
        console.error('加载展商须知数据失败:', error)
        exhibitorNotice.value = []
      }
    }
    
    onMounted(() => {
      loadExhibitorNotice()
    })

    // 重要提醒数据
    const importantReminders = ref([])
    
    // 加载重要提醒数据
    const loadImportantReminders = async () => {
      try {
        const response = await subpageApi.getSubpageByKey('exhibitors', 'important-reminders')
        if (response && response.code === '200' && response.data) {
          const data = response.data
          if (data.content) {
            try {
              const contentData = JSON.parse(data.content)
              importantReminders.value = contentData.reminders || []
            } catch (e) {
              console.error('解析重要提醒数据失败:', e)
              importantReminders.value = []
            }
          } else {
            importantReminders.value = []
          }
        } else {
          importantReminders.value = []
        }
      } catch (error) {
        console.error('加载重要提醒数据失败:', error)
        importantReminders.value = []
      }
    }

    // 参展要求数据
    const requirements = ref([])
    
    // 加载参展要求数据
    const loadRequirements = async () => {
      try {
        const response = await subpageApi.getSubpageByKey('exhibitors', 'exhibition-requirements')
        if (response && response.code === '200' && response.data) {
          const data = response.data
          if (data.content) {
            try {
              const contentData = JSON.parse(data.content)
              requirements.value = contentData.requirements || []
            } catch (e) {
              console.error('解析参展要求数据失败:', e)
              requirements.value = []
            }
          } else {
            requirements.value = []
          }
        } else {
          requirements.value = []
        }
      } catch (error) {
        console.error('加载参展要求数据失败:', error)
        requirements.value = []
      }
    }

    // 时间安排数据
    const scheduleItems = ref([])
    
    // 加载时间安排数据
    const loadScheduleItems = async () => {
      try {
        const response = await subpageApi.getSubpageByKey('exhibitors', 'schedule-timeline')
        if (response && response.code === '200' && response.data) {
          const data = response.data
          if (data.content) {
            try {
              const contentData = JSON.parse(data.content)
              scheduleItems.value = contentData.schedule || []
            } catch (e) {
              console.error('解析时间安排数据失败:', e)
              scheduleItems.value = []
            }
          } else {
            scheduleItems.value = []
          }
        } else {
          scheduleItems.value = []
        }
      } catch (error) {
        console.error('加载时间安排数据失败:', error)
        scheduleItems.value = []
      }
    }

    // 获取图标组件
    const getIconComponent = (iconName) => {
      const iconMap = {
        'Warning': Warning,
        'Clock': Clock,
        'Document': Document,
        'Setting': Setting,
        'Location': Location,
        'User': User,
        'Tools': Tools
      }
      return iconMap[iconName] || Warning
    }

    return {
      exhibitorNotice,
      importantReminders,
      requirements,
      scheduleItems,
      getIconComponent
    }
  }
}
</script>

<style scoped>
.exhibitornotice {
  min-height: 100vh;
  background: linear-gradient(135deg, #320063 0%, #4a0a8a 100%);
}

.page-header {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 120px 0 80px 0;
  margin-top: 0;
  text-align: center;
  color: white;
}

.page-title {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.page-subtitle {
  font-size: 1.2rem;
  opacity: 0.9;
  margin-bottom: 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.content-section {
  background: white;
  border-radius: 20px;
  padding: 3rem;
  margin: 2rem 0;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.section-title {
  font-size: 2rem;
  color: #333;
  margin-bottom: 2rem;
  text-align: center;
  position: relative;
  padding-left: 15px;
}

.section-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 2px;
}

/* 展商须知样式 */
.exhibitor-notice {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
}

.notice-item {
  padding: 30px 20px;
  background: #f8f9fa;
  border-radius: 12px;
  transition: transform 0.3s ease;
}

.notice-item:hover {
  transform: translateY(-5px);
}

.notice-item h3 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 15px;
}

.notice-item p {
  color: #666;
  line-height: 1.5;
}

/* 重要提醒样式 */
.important-reminders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
}

.reminder-item {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 25px;
  background: #f8f9fa;
  border-radius: 12px;
  transition: transform 0.3s ease;
}

.reminder-item:hover {
  transform: translateY(-5px);
}

.reminder-icon {
  font-size: 2.5rem;
  color: #667eea;
  flex-shrink: 0;
}

.reminder-content h3 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
}

.reminder-content p {
  color: #666;
  line-height: 1.5;
}

/* 参展要求样式 */
.exhibition-requirements {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px;
}

.requirement-category {
  padding: 25px;
  background: #f8f9fa;
  border-radius: 12px;
  transition: transform 0.3s ease;
}

.requirement-category:hover {
  transform: translateY(-5px);
}

.requirement-category h3 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 15px;
}

.requirement-list {
  list-style: none;
  padding: 0;
}

.requirement-list li {
  color: #666;
  line-height: 1.6;
  margin-bottom: 8px;
  padding-left: 20px;
  position: relative;
}

.requirement-list li::before {
  content: '•';
  color: #667eea;
  font-weight: bold;
  position: absolute;
  left: 0;
}

/* 时间安排样式 */
.schedule-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 12px;
  transition: transform 0.3s ease;
}

.timeline-item:hover {
  transform: translateY(-5px);
}

.timeline-marker {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  flex-shrink: 0;
}

.timeline-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.timeline-date {
  color: #667eea;
  font-weight: 500;
  margin-bottom: 8px;
}

.timeline-content p {
  color: #666;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .page-title {
    font-size: 2rem;
  }
  
  .content-section {
    padding: 2rem;
    margin: 1rem 0;
  }
  
  .section-title {
    font-size: 1.5rem;
  }
}
</style>